#include <stdio.h>
#include <nspr4/nspr.h>


PRLock* g_lock;

void Thread_A(char* buf)
{
    PR_Lock(g_lock);
    for (int i = 0; i < 5; i++)
    {
        printf("In thread A %d:  %s\n", i,buf);
    }
    PR_Unlock(g_lock);
}


int main()
{
    PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
    PRThread* p_tha;
    g_lock = PR_NewLock(); 
    p_tha = PR_CreateThread(PR_USER_THREAD,
                                    (void (PR_CALLBACK *)(void *))Thread_A,
                                    "buffer to thread A",
                                    PR_PRIORITY_HIGH,
                                    PR_LOCAL_THREAD,
                                    PR_JOINABLE_THREAD,
                                    0);

    PR_JoinThread(p_tha);
    PR_DestroyLock(g_lock);
    PR_Cleanup();
    return 0;
}